import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class test4 {
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("Java_11_16\\d.txt");
        StringBuilder sb = new StringBuilder();
        int b;
        while((b = fr.read()) != -1) {
            sb.append((char)b);
        }

        Integer[] arr = Arrays.stream(sb.toString().split("-")).map(Integer::parseInt).sorted().toArray(Integer[]::new);

        FileWriter fw = new FileWriter("Java_11_16\\e.txt");
        for (int i = 0; i < arr.length; i++) {
            fw.write(arr[i] + "");
            if(i != arr.length-1) {
                fw.write('-');
            }
        }
        fw.close();
        fr.close();
    }
}
